echo "开始运行！"
echo " 关闭服务"
sudo service mysqld stop
sudo sed -i "s/#skip-grant-tables/skip-grant-tables/g" /etc/my.cnf
echo " 启动服务"
sudo service mysqld start
mysql -u root <<EOF
use mysql;
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123123';
FLUSH PRIVILEGES;
EOF
echo " 关闭服务"
sudo service mysqld stop
sudo sed -i "s/skip-grant-tables/#skip-grant-tables/g" /etc/my.cnf
echo " 启动服务"
sudo service mysqld start
mysql -u root -p123123 <<EOF
use mysql;
FLUSH PRIVILEGES;
CREATE USER 'root'@'%' IDENTIFIED  WITH mysql_native_password BY '123123';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EOF
echo " Mysql允许远程登录"
echo "运行结束！"